﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Image_Processing_Website.UserControls
{
    public partial class ImageUserControl : System.Web.UI.UserControl
    {
        #region private members

        private List<String> m_imageURLs = null;

        #endregion

        #region protected methods
        protected override void OnInit(EventArgs e)
        {
            m_imageURLs = new List<String>();
            m_imageURLs.Add(@"http://i.minus.com/ibzIMXKdIUiqZL.jpg");
            m_imageURLs.Add(@"http://i.minus.com/i8kMJZ3YvXNaK.jpg");
            m_imageURLs.Add(@"http://i.minus.com/iWj5GjCUsDyLa.jpg");
            m_imageURLs.Add(@"http://i.minus.com/ipFnPAltzV96v.jpg");
            m_imageURLs.Add(@"http://i.minus.com/ibvAHxLlUl8bMy.jpg");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                imgProcessed.ImageUrl = getRandomImage();
            }
        }

        #endregion

        #region private methods

        private String getRandomImage()
        {
            int randomIndex = (new Random()).Next(0, m_imageURLs.Count);            
            return m_imageURLs[randomIndex];
        }

        #endregion
    }
}